package cn.edu.sgu.www.mhxysy.service.jingmai.impl;

import cn.edu.sgu.www.mhxysy.entity.jingmai.JingmaiType;
import cn.edu.sgu.www.mhxysy.mapper.jingmai.JingmaiTypeMapper;
import cn.edu.sgu.www.mhxysy.service.jingmai.JingmaiTypeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Service
public class JingmaiTypeServiceImpl implements JingmaiTypeService {

    private final JingmaiTypeMapper jingmaiTypeMapper;

    @Autowired
    public JingmaiTypeServiceImpl(JingmaiTypeMapper jingmaiTypeMapper) {
        this.jingmaiTypeMapper = jingmaiTypeMapper;
    }

    @Override
    public List<JingmaiType> selectAll() {
        QueryWrapper<JingmaiType> queryWrapper = new QueryWrapper<>();

        queryWrapper.notInSql("id",
                "select parent_id from jingmai_type where parent_id is not null");

        return jingmaiTypeMapper.selectList(queryWrapper);
    }

    @Override
    public JingmaiType selectById(Integer id) {
        return jingmaiTypeMapper.selectById(id);
    }

}